package com.fjw.service.impl;

import com.fjw.dao.SysMenuMapper;
import com.fjw.pojo.SysMenu;
import com.fjw.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
public class SysMenuServiceImpl implements SysMenuService {
    //注入dao
    @Autowired
    private SysMenuMapper sysMenuMapper;

    @Override
    public Set<SysMenu> findByUsername(String username) {
        Set<SysMenu> menuList = sysMenuMapper.findByUsernameAndParentId(username,0);
        for (SysMenu sysMenu : menuList) {
            Set<SysMenu> byParentId = sysMenuMapper.findByUsernameAndParentId(username,sysMenu.getMenuId());
            sysMenu.setList(byParentId);
        }
        return menuList;
    }



}
